package com.ougy.reshop.action.manager;

import org.apache.log4j.Logger;
import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ModelDriven;
import com.ougy.reshop.model.Album;
import com.ougy.reshop.model.Publish;
import com.ougy.reshop.model.Region;
import com.ougy.reshop.model.User;
import com.ougy.reshop.vo.PublishInfo;

public class PublishAction extends BaseUploadAction implements ModelDriven<PublishInfo>{
	/**
	 * 
	 */
	private static final long serialVersionUID = 8587363034032645922L;
	private Logger logger = Logger.getLogger(getClass());
	
	private PublishInfo info=new PublishInfo();
	
	public PublishInfo getInfo() {
		return info;
	}
	public void setInfo(PublishInfo info) {
		this.info = info;
	}
	@Override
	public PublishInfo getModel() {
		return info;
	}

	@Override
	public String execute() throws Exception {
		Region twoLevel=(Region) ServletActionContext.getRequest().getAttribute("city");
		Album album=uploadMore();
		Publish publish=new Publish();
		publish.setId(getUuid());
		publish.setType(info.getType());
		publish.setTitle(info.getTitle());
		publish.setPrice(info.getPrice());
		publish.setDescContent(info.getDescContent());
		publish.setPubGoodClass(info.getMinorGoodsclass());
		publish.setThreeLevel(info.getThreeLevel());
		publish.setTelPhone(info.getTelPhone());
		publish.setQq(info.getQq());
		publish.setLinkmanName(info.getLinkmanName());
		publish.setShowImage(album);
		publish.setOwner((User)session.get("user"));
		publish.setTwoLevel(twoLevel);
		sPublish.post(publish);
		return "success";
	}
}
